<?php
/*
* PHP Template created by Nicky
*/

include_once 'AdminController.php';

class user extends AdminController{
	
	var $pageSize = 1000 ;
	
	function _construct(){
		parent::__construct();
		if(empty($_SESSION['LOGIN'])){
		 	echo '<script>window.top.location = "/admin.php?c=main&a=login";</script>';
		 	exit();
		 } 
	}
 
	
	function index(){
		$page = empty($_GET['page'])?1:$_GET['page'];
		$page = $page<1 ? 1 : $page ; 
		
		$where = ' 1=1 ';
		$whereArray = array();
		$whereStr = ''; 

		$limtestr = (intval($page)-1)*$this->pageSize.','.$this->pageSize;		
		$userModel = spClass('m_wx_user');	
		$gameModel = spClass('m_wx_game');
		$totalCount = $userModel->findCount($where);
		$pager = array(
			'totalCount'	=>	$totalCount,
			'pageSize'		=>	$this->pageSize,
			'queryStr'		=>	$whereStr,
			'currentPage'	=>	$page,
			'url'			=>	'/admin.php?c=user&a=index'
		);
		$dataList = $userModel->findAll($where,'id desc',null,$limtestr);  
		$list = array();
		foreach($dataList as $dl){
			$dl['nickname'] = base64_decode($dl['nickname']);
			if($dl['sex']==1){
				$dl['sex'] = '男';
			}elseif($dl['sex']==2){
				$dl['sex'] = '女';
			}else{
				$dl['sex'] = '未知';
			} 
			$dl['money'] = $gameModel->getMoney($dl['openid']);
			$list[] = $dl;
		}
		$this->dataList = $list;
		$this->whereArray = $whereArray;
		$this->whereStr = 'page='.$page.$whereStr; 
		$this->pager = $this->getPager($pager);
		
	}
}